package cn.kgc.shiro02.commons;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/4/4
 * @Description:  layui表格数据格式封装类
 */
@ApiModel(description = "响应数据封装实体类")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)  // 转换数据格式时 只转换不为null的值
public class ResponseResult{

    @ApiModelProperty(value = "提示信息",required = true,dataType = "String",example = "操作成功")
    private String msg;
    @ApiModelProperty(value = "状态码",required = true,dataType = "Integer",example = "0")
    private Integer code;
    @ApiModelProperty(value = "分页数据的总条数",required = false,dataType = "Long",example = "10")
    private Long count;
    @ApiModelProperty(value = "当前页数据",required = false,dataType = "Object")
    private Object data;

    // 没有数据的响应
    public ResponseResult (CodeMsg codeMsg){
        this.code = codeMsg.getCode();
        this.msg = codeMsg.getMsg();
    }

    //有数据的响应
    public ResponseResult (CodeMsg codeMsg,Long count,Object data){
        this(codeMsg);
        this.count = count;
        this.data = data;
    }

}
